package com.glsc.ngateway.common.base.domain.mysql.gateway.platform.it.networkassets;

import com.glsc.ngateway.common.base.annotation.EncryptField;
import com.glsc.ngateway.common.base.domain.mysql.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;
import java.io.Serializable;

/**
 * 主机信息维护
 * @author xuchang
 */
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@Entity
@Where(clause = "deleted = 0")
@SQLDelete(sql = "update t_gw_it_net_assets_host_information set deleted = UNIX_TIMESTAMP(NOW()) where id=?")
@SQLDeleteAll(sql = "update t_gw_it_net_assets_host_information set deleted = UNIX_TIMESTAMP(NOW()) where id=?")
@Table(name = "t_gw_it_net_assets_host_information", indexes = {@Index(name = "UK_HOST", columnList = "host, deleted", unique = true)})
public class HostInformationMaintenance extends BaseEntity implements Serializable  {

    private static final long serialVersionUID = 7054247857549088573L;

    @Column(name = "host", columnDefinition = "varchar(128) not null comment '主机'")
    private String host;

    @Column(name = "hostname", columnDefinition = "varchar(128) comment '主机名'")
    private String hostname;

    @Column(name = "service_zone", columnDefinition = "varchar(64) comment '业务区域'")
    private String serviceZone;

    @Column(name = "device_role", columnDefinition = "varchar(64) comment '设备角色'")
    private String deviceRole;

    @Column(name = "snmp_version", columnDefinition = "varchar(8) comment 'SNMP版本'")
    private String snmpVersion;

    @EncryptField
    @Column(name = "snmp_ro_community", columnDefinition = "varchar(128) comment 'SNMP只读团体字'")
    private String snmpRoCommunity;

    @Column(name = "mgmt_interface", columnDefinition = "varchar(8) comment '远程管理接口'")
    private String mgmtInterface;

    @EncryptField
    @Column(name = "username", columnDefinition = "varchar(128) comment '用户名'")
    private String username;

    @EncryptField
    @Column(name = "password", columnDefinition = "varchar(128) comment '密码'")
    private String password;

    @Column(name = "task", columnDefinition = "varchar(128) comment '任务列表'")
    private String task;

    @Column(name = "hostid", columnDefinition = "int comment '绑定监控'")
    private Integer hostid;

    @Column(name = "bind_serial_num", columnDefinition = "varchar(512) not null comment '绑定设备资产'")
    private String bindSerialNum;

    @Column(name = "deployed_mode", columnDefinition = "varchar(64) not null comment '部署模式'")
    private String deployedMode;

    @Column(name = "peer", columnDefinition = "varchar(128) comment '对端主机'")
    private String peer;

}
